package cn.tedu.charging.user.dao.repository;

import cn.tedu.charging.common.pojo.po.ChargingVehiclePO;
import cn.tedu.charging.user.dao.mapper.ChargingVehicleMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class VehicleRepository {
    @Autowired
    private ChargingVehicleMapper chargingVehicleMapper;

    public ChargingVehiclePO getVehicleById(Integer vehicleId) {
        //使用主键 有现成方法
        return chargingVehicleMapper.selectById(vehicleId);
    }

    public ChargingVehiclePO getVehicleByLicense(String license) {
        QueryWrapper<ChargingVehiclePO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("license",license);
        return chargingVehicleMapper.selectOne(queryWrapper);
    }

    public void save(ChargingVehiclePO vehicle) {
        chargingVehicleMapper.insert(vehicle);
    }
}
